package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2023/3/16 10:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult listAll() {
        return wmChannelService.findAll();
    }

    @ApiOperation("根据id删除频道")
    @GetMapping("/del/{id}")
    public ResponseResult delById(@PathVariable Integer id) {
        return wmChannelService.delById(id);
    }

    @ApiOperation("频道名称模糊分页查询")
    @PostMapping("/list")
    public ResponseResult listPage(@RequestBody WmChannelDto wmChannel) {
        return wmChannelService.listPage(wmChannel);
    }

    @ApiOperation("保存频道")
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel) {
        return wmChannelService.saveChannel(wmChannel);
    }

    @ApiOperation("修改频道")
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel) {
        return wmChannelService.updateChannel(wmChannel);
    }

}